package enemies;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.util.ArrayList;

import javax.swing.ImageIcon;

import projectiles.Bullet;
import projectiles.Projectile;

public class Jeep extends MobileEnemy{
	
	private static final ImageIcon image = new ImageIcon("images/jeep.gif");
	private static final ImageIcon deviceImage = new ImageIcon("images/jeepgun.gif");
	
	public Jeep(ArrayList<Point2D.Double> route, Point2D.Double position, int health, int speed) {
		super(route, position, health, new Dimension(image.getIconWidth(), image.getIconHeight()), image, 500, 200, speed, deviceImage, 0 );
	}
	
	public Projectile shoot(){
		updateFirerate();

		return new Bullet( this, getPosition(), deviceAngle, aimAtTower.getMiddle());
	}
	
	public void draw(Graphics g, Rectangle area, Component c )
	{
		super.draw(g, area, c);
		Graphics2D g2d = (Graphics2D)g;
	    g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);

	    AffineTransform oldForm = g2d.getTransform();
	    AffineTransform newForm = (AffineTransform) g2d.getTransform().clone();
	    
	    newForm.rotate(Math.toRadians(this.deviceAngle), (int)getMiddle().x, (int)getMiddle().y);
	    
	    g2d.setTransform(newForm);
		g2d.drawImage(deviceImage.getImage(), (int)this.position.x+(image.getIconWidth()/2)-deviceImage.getIconWidth()/2, (int)this.position.y + (image.getIconHeight()/2)-deviceImage.getIconHeight()/2, c );
		g2d.setTransform(oldForm);
		
		
	}

}
